
//public class ParticipantRoleDaoImpl extends PmsBaseDaoImpl<ParticipantRoleDO>
//implements IParticipantRoleDao{
//	/**
//	 * obj[0]=participantRoleId;obj[1]=participantId;obj[2]=participantName;
//	 */
//	public Object[] getParticipantRoleBy(Long participantId)
//	{
//		String hql = "from ClientDO client where client.participant.participantId= ?";
//
//		Query query = createQuery(hql, new Long[]{participantId});
//		if(BlankUtil.isBlank(query.uniqueResult())){
//			return null;
//		}
//		Object obj =  query.uniqueResult();
//		Object[] objList = new Object[3];
//
//		ClientDO  clientDO = (ClientDO) obj;
//		ParticipantDO participant = clientDO.getParticipant();
//		objList[0] = clientDO.getParticipantRoleId();
//		objList[1] = participant.getParticipantId();
//		objList[2] = participant.getParticipantName();
//
//		return objList;
//	}
//}

package com.ce.pms.customer.dao.impl;

import org.hibernate.Query;
import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.customer.dao.IParticipantRoleDao;
import com.ce.pms.customer.model.ClientDO;
import com.ce.pms.customer.model.ParticipantDO;
import com.ce.pms.customer.model.ParticipantRoleDO;
import com.ce.util.BlankUtil;

public class ParticipantRoleDaoImpl extends PmsBaseDaoImpl<ParticipantRoleDO>
implements IParticipantRoleDao{
	/**
	 * obj[0]=participantRoleId;obj[1]=participantId;obj[2]=participantName;
	 */
	public Object[] getParticipantRoleBy(Long participantId,Long houseId)
	{
		String hql = "from ClientDO client inner join client.clientRHouses cr where client.participant.participantId= ? and cr.house.id = ?";

		Query query = createQuery(hql, participantId,houseId);

		if(BlankUtil.isBlank(query.list())){
			return null;
		}

		Object[] obj =  (Object[]) query.list().get(0);
		Object[] objList = new Object[3];

		ClientDO  clientDO = (ClientDO) obj[0];
		ParticipantDO participant = clientDO.getParticipant();
		objList[0] = clientDO.getParticipantRoleId();
		objList[1] = participant.getParticipantId();
		objList[2] = participant.getParticipantName();

		return objList;

	}


}
